/*
* 普通转诊
* */

$(function () {

    let myChart = echarts.init(document.getElementById("ptzzLineChart"));
    let option = {
        tooltip: {},
        grid: {
            top: 20,
            bottom: 40,
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
            axisLabel: {
                fontSize: 12,
                color: "#b0c2f9",
                interval:0,//横轴信息全部显示
                rotate:-30,//-30度角倾斜显示
            }
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                fontSize: 12,
                color: "#b0c2f9"
            }
        },
        series: [
            {
                data: [ 820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290 ],
                type: 'line',
                color: ['#7760f6'],
                areaStyle: {},
                lineStyle: {
                    color: '#e6b600',
                    width: 2
                },
            }
        ]
    };

    if (option && typeof option === "object") {
        myChart.setOption(option, true);
    }

    $.ajax({
        url: "/hospital/total/common",
        dataType: "json"
    }).done(function(data) {
        // console.log('Data: ', data);
        const xData = [];
        for(let i in data.result) {
            xData.push(data.result[i].count);
        }
        myChart.setOption({
            series: [{
                data: xData
            }]
        });
    }).fail(function(jqXHR) {
        console.log("Ajax Fail: ", jqXHR.status, jqXHR.statusText);
    });

    //浏览器窗口大小变化时，重置报表大小
    $(window).resize(function() {
        myChart.resize();
    });

});